<?php

class paomeRankController extends base
{
    public function __construct()
    {
        parent::__construct('admin');
        // 判断权限
        if(empty($this->realUser['uid']) || !$this->load('adminList')->isAdminByHupuUid($this->realUser['uid']))
        {
            echo 'jrs, 不要四处乱看哦～～';
            exit();
        }
    }

    public function doinit() {}

   /**
    * 排行榜列表
    */
    public function dogetRankList() {
        $paomeId =  common::request('paomeId','R',0);//赛季ID
        $contestStatus = common::request('contestStatus','R',1);//赛季阶段
        if (!$paomeId) {
            common::tips('参数丢失');exit;
        }
        $arrStatus = array(//page 选择
            array('name'=>'第一轮','id'=>1),
            array('name'=>'第二轮','id'=>5),
            array('name'=>'冠军争霸赛','id'=>100)
        );
        $name   = common::request('name','R','');//俱乐部名称
        $typeWd   = common::request('typeWd','R',1);
        $listNum = 20;
        $p = common::request('p', 'G', 1);
        $start = ($p - 1) * $listNum;
        $parameter = '';
        $params = [];
        $params['paomeId'] = $paomeId;
        $params['typeWd'] = $typeWd;//排名维度:1 总里程 5 配速 10 人气 15 全员跑量榜
        $params['contestStatus'] = $contestStatus;
        $parameter .= '&paomeId='.$paomeId.'&typeWd='.$typeWd.'&contestStatus='.$contestStatus;
        if (trim($name)) {
            $parameter .= '&name='."'$name'";
            $params['name'] = $name;
        }
        $params['start'] = $start;
        $params['limit'] = $listNum;
        $list = $this->load('paome/rank')->getRankList($params);
        /*if($list) {
            foreach ($list as $key=>$val) {
                $arrClubInfo = $this->load('paome/paomeClub')->getClubInfo($val['club_id'],'title,image');
                $list[$key]['clubName'] = isset($arrClubInfo['title']) ? $arrClubInfo['title'] : '';
                $list[$key]['clubImage'] = isset($arrClubInfo['image']) ? $arrClubInfo['image'] : '';
                if ($val['type_wd'] == 15) {//全员跑量榜
                    $header = $this->redis->hget(REDIS_PREFIX . 'UserInfo_' . $val['object_id'],'header');
                    $nickname = $this->redis->hget(REDIS_PREFIX . 'UserInfo_' . $val['object_id'],'nickname');
                    $list[$key]['userHeader'] = $header;
                    $list[$key]['userNickName'] = $nickname;
                }
                if ($val['type_wd'] == 5) {
                    $list[$key]['rand_value'] = common::sec2time($val['rand_value']);
                }
            }
        }*/
        $total = $this->load('paome/rank')->total;
        require FILE . 'lib/page.class.php';
        $page = new Page($total, $listNum, $parameter);
        $pageStr = $page->show();

        $this->view->assign('list', $list);
        $this->view->assign('pageStr', $pageStr);
        $this->view->assign('name', $name);
        $this->view->assign('contestStatus', $contestStatus);
        $this->view->assign('typeWd', $typeWd);
        $this->view->assign('paomeId', $paomeId);
        $this->view->assign('arrStatus',$arrStatus);
        $this->view->display('paome/rankList');

    }




}